<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>
<head>
	<title>备案申报</title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>备案申报</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
			<li class="active"><a href="#"><i class="active"></i>交易</a></li>
            <li class="active"><a href="#"><i class="active"></i>备案采购</a></li>
            <li class="active"><a href="#"><i class="active"></i>备案申报</a></li>
        </ol>
    </section>
    

    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <div class="input">
                	<div class="textalign1">通用名：</div>
                        <div class="boxinput">
                        <input type="text" class="textinput"  id="drugName" placeholder="通用名" />
                    	</div>
					<div class="textalign1">药品编码：</div>
                        <div class="boxinput">
                        <input type="text" class="textinput"  id="drugCode" placeholder="药品编码" />
                    	</div>
                    
                    <div class="textalign1">生产企业：</div>
                        <div class="boxinput">
                        <input type="text" class="textinput"  id="compName" placeholder="生产企业" />
                        <input type="hidden" id="compCode" />
                    	</div>
                    <div class="textalign1" >
                    <button  id="selectSee" type="button" class="btn btn-success btn-sm" onclick="search()">查 询</button>
                </div>
                </div>
            </div>
        </div>
        
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
        
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    
    <script type="text/javascript">
    
  //绑定回车   id="selectSee"
    $('#drugName,#compName,#drugCode').bind('keydown', function(event) {
        if (event.keyCode == "13") {
            $('#selectSee').click();
        }
    }); 
    $("#drugName").focus();//加载页面光标在第一个查询框内
    
		function search(page) {
			var drugName = $.trim($("#drugName").val());
			var drugCode = $.trim($("#drugCode").val());
			var compCode = $.trim($("#compCode").val());
			if ((drugName == null || drugName == "")
					&& (drugCode == null || drugCode == "") 
					&& (compCode == null || compCode == "")) {
				$.alert("请输入查询条件！", "warn");
				return;
			}
			 //展示列表
            $($("#gview_gridlist").children()[1]).show();
            $($("#gview_gridlist").children()[2]).show();
            $("#gridpage").show();  
            $(".HeaderButton").show();
            
			$("#gridlist").jqGrid('setGridParam',{
				url: "getAddList.html",
				mtype: "POST",
		        datatype:'json',
		        postData:{"drugCode":drugCode, "drugName":drugName, "compCode":compCode},
		        page : (page || 1)
		    }).trigger("reloadGrid"); //重新载入  
		}

        $(function () {
        	
        	$("#compName").fuzzySearchComp(function(compCode) {
        		$("#compCode").val(compCode);
        	});
        	
            $("#gridlist").jqGrid({
                mtype: "POST",
                datatype: "json",
                autowidth: true,
               // height: 353,
                colNames: ['操作', '药品编码', '通用名', '剂型', '规格', '转换系数', '单位', '材质', '生产企业'],
                colModel: [
					{ name: 'operate', width: 100, align: "center", sortable:false,
						formatter : function(val, opts, rowdata) {
							return "<a href='toBakDrugAdd.html?drugCode="+rowdata.drugCode+"'>申请备案</a>";
						}
					},
				    { name: 'drugCode', width: 120, align:'center', sortable:false,
			        	formatter:function(cellvalue, options, row) {
			        		return drugInfoLink(cellvalue);
			        	}
				    },
                    { name: 'drugName', width: 160, align:'left', sortable:false},
                    { name: 'formName', width: 80 ,align: 'center', sortable:false},
                    { name: 'specName', width: 120 ,align: 'left', sortable:false},
                    { name: 'factor', width: 80 ,align: 'center', sortable:false},
                    { name: 'unitName', width: 80 ,align: 'center', sortable:false},
                    { name: 'materialName', width: 80 ,align: 'left', sortable:false},
                    { name: 'compName', width: 160 ,align: 'left', sortable:false}
                ],
                rowNum: 20,
                rowList: [10, 20, 50, 100],
                rownumbers: true,
                pager: "#gridpage",
                viewrecords: true,
                caption: "<span style='color:#fff;'>请输入查询条件，查询可备案药品！</span>",
                jsonReader: {
                    repeatitems: false
                }
            });
            
            //隐藏列表
            $($("#gview_gridlist").children()[1]).hide();
            $($("#gview_gridlist").children()[2]).hide();
            $("#gridpage").hide();
            $(".HeaderButton").hide();
            
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            
            $(window).trigger("resize");
            $("#gridlist").jqGrid("setGridHeight", create());
            
        });
    </script>
</body>
</html>